using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Attack : MonoBehaviour
{
  public int damage;
  public int range;
  public int rate;

  /// <summary>
  /// Sent each frame where another object is within a trigger collider
  /// attached to this object (2D physics only).
  /// 目前只处理了碰撞伤害
  /// </summary>
  /// <param name="other">The other Collider2D involved in this collision.</param>
  private void OnTriggerStay2D(Collider2D other)
  {
    // if (other.name == "Player")
    // 两个物体碰撞时，挂载了Attack脚本的物体，让对方触发受伤 takeDamage
    // 人物没挂这个脚本，人物与敌人碰撞时，人物的takeDamage触发，但是野猪不会触发
    // Attack Area 和 敌人挂了这个脚本，但是Attack Area 没有 takeDamage。如果后期增加耐久度，倒是可以
    other.GetComponent<Character>()?.TakeDamage(this);
  }
}
